<?php

include_once './php-ofc-library/open-flash-chart.php';

		$link= mysql_connect("localhost","root","")or die ('Error connecting to mysql');
		$sdb=mysql_select_db("asodeco");
		$query="SELECT factor.enunciado AS fact FROM factor WHERE factor.id= '".$_GET["tit"]."';";
		$result=mysql_query($query ,$link);
		$row=mysql_fetch_array($result);
		$tit=$row['fact'];
		
$max= max((int)$_GET["pos"],(int)$_GET["neg"],(int)$_GET["mneg"]);
$valor=0;
$tope=round($max+(0.2*$max));
$entre=round($max*0.1);
//$x_labels = range(0,$tope,$entre);

$title = new title( $tit);

$hbar = new hbar( '#86BBEF' );
$hbar->set_tooltip( '#val#' );
$hbar->append_value( new hbar_value(0,(int)$_GET["pos"]) );
$hbar->append_value( new hbar_value(0,(int)$_GET["neg"]) );
$hbar->append_value( new hbar_value(0,(int)$_GET["mneg"]) );

$chart = new open_flash_chart();
$chart->set_title( $title );
$chart->add_element( $hbar );

$x = new x_axis();
$x->set_offset( false );
$x->set_range( 0, round($max+(0.2*$max)));
$x->set_steps( round($max*0.1));
//$x->set_labels_from_array( $x_labels );
$chart->set_x_axis( $x );

$x_legend = new x_legend( 'Asodeco C.A.' );
$x_legend->set_style( '{font-size: 12px; color: #0066FF; align:right}' );
$chart->set_x_legend( $x_legend );

$y = new y_axis();
$y->set_offset( true );
$y->set_labels( array( "Muy Negativo","Negativo","Positivo" ) );
$chart->add_y_axis( $y );

echo $chart->toPrettyString();